﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;

namespace whuc.PlaneGame
{
    /// <summary>
    /// 爆炸动画的对象
    /// </summary>
    public class Boom
    {
        //小飞机爆炸的图片数组
        public Image[] imgs0 = { 
                               Properties.Resources.enemy0_down11,
                               Properties.Resources.enemy0_down2,
                               Properties.Resources.enemy0_down3,
                               Properties.Resources.enemy0_down4
                               };
        //中飞机爆炸的图片动画
        public Image[] imgs1 = { 
                               Properties.Resources.enemy1_down11,
                               Properties.Resources.enemy1_down2,
                               Properties.Resources.enemy1_down3,
                               Properties.Resources.enemy1_down4
                               };
        //大飞机爆炸的图片数组
        public Image[] imgs2 ={
                               Properties.Resources.enemy2_down11,
                               Properties.Resources.enemy2_down2,
                               Properties.Resources.enemy2_down3,
                               Properties.Resources.enemy2_down4,
                               Properties.Resources.enemy2_down5,
                               Properties.Resources.enemy2_down6
                             };
        /**
         * 敌机在哪里死亡，爆炸就在哪里产生
         */
        public Enemy enemyPlane { get; set; }
        public Image[] imgs { get; set; }
        public int Width { get; set; }
        public int Height { get; set; }
        public Boom(Enemy enemyPlane)
        {
            this.enemyPlane = enemyPlane;
            //图片根据飞机的类型确定以后
            if (this.enemyPlane.Type==0)
            {
                this.imgs = this.imgs0;
            }
            else if (this.enemyPlane.Type==1)
            {
                this.imgs = this.imgs1;
            }
            else if(this.enemyPlane.Type==2)
            {
                this.imgs = this.imgs2;
            }
            this.Width = this.imgs[0].Width;
            this.Height = this.imgs[0].Height;
        }


        /// <summary>
        /// 绘画游戏对象
        /// </summary>
        /// <param name="g"></param>
        public void Draw(Graphics g)
        {
            for (int i = 0; i < this.imgs.Length; i++)
            {
                g.DrawImage(this.imgs[i],this.enemyPlane.X,this.enemyPlane.Y,this.Width,this.Height);
            }
            //当爆炸动画播放完成以后，就要移除自己
            DataUtil.boomList.Remove(this);
        }
    }
}
